/*
 * Author: hujingfei914@msn.com
 * Date:   2010-10-14
 * Description: A custom picture control supporting rendering using OpenGL
 */
#pragma once
#include "afxwin.h"
#include <gl/gl.h>
#include <gl/glu.h>
#include "..\helisys\heli_sys_define\FlyStructDefine.h"
//class CAircraft;
class C3DSAircraft;

class COpenGLControl :
	public CWnd
{
// Attributes
public:
	UINT_PTR m_unpTimer;

private:
	CWnd *hWnd;
	HDC hdc;
	HGLRC hrc;
	int m_nPixelFormat;
	CRect m_rect;
	CRect m_oldWindow;
	CRect m_originalRect;

	// Camera's parameters
	GLfloat m_fPosX, m_fPosY, m_fZoom, m_fRotX, m_fRotY;

	// Aircraft model 
	//CAircraft *aircraft;

	// Spaceship model
	C3DSAircraft *spaceship;

public:
	COpenGLControl(void);
	~COpenGLControl(void);
	void oglCreate(CRect rect, CWnd *parent);
	void oglInitialize(void);
	void oglInitializeIlluminationAndMaterial(void);
	void updateAircraft(const FlyState &flyState);

public:
	DECLARE_MESSAGE_MAP()
	afx_msg void OnPaint();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDraw(CDC *pDC);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
};
